package com.googlecode.connectlet.dictionary;

import java.util.ArrayList;

import com.googlecode.connectlet.util.db.DBExecutor;
import com.googlecode.connectlet.util.db.Row;
import com.googlecode.connectlet.util.db.RowCallback;

public class DictUtil {
	public static int CLP(char c, int len, int pos) {
		return c * 1024 + len * 32 + pos;
	}

	public static ArrayList<String> matchWords(char c, int len, int pos) {
		String sql = "SELECT word FROM dict_clp, dict_word WHERE dict_clp.id = dict_word.id AND clp = ?";
		final ArrayList<String> result = new ArrayList<String>();
		DBExecutor.getInstance().query(1, new RowCallback() {
			@Override
			public boolean onRow(Row row) {
				result.add(row.getString(1));
				return true;
			}
		}, sql, CLP(c, len, pos));
		return result;
	}
}